package it.allerj.model;

import it.allerj.common.persistence.PersistenceObject;

import it.allerj.demo.DemoConfiguratorMatrix;
import it.allerj.gui.action.FactoryGuiActionProxy;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author Alessandro Veracchi
 * @version 1.0
 * @created 12-apr-2008 12.10.03
 */
public class AllergicTest extends PersistenceObject{
	private List<Frame> frameList = new ArrayList<Frame>();
	private Date date;
	private String reagentBarcode;
        private Patient patient;
	
	public List<Frame> getFrameList() {
		return frameList;
	}
	public void setFrameList(List<Frame> frameList) {
		this.frameList = frameList;
	}
	public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}
	public String getReagentBarcode() {
		return reagentBarcode;
	}
	public void setReagentBarcode(String reagentBarcode) {
		this.reagentBarcode = reagentBarcode;
	}

    public Patient getPatient() {
        return patient;
    }

    public void setPatient(Patient patient) {
        this.patient = patient;
    }
    
    public void initEmptyAllergicTest() {
       
        if(this.getFrameList()==null || this.getFrameList().size()==0){
            this.setFrameList(new ArrayList<Frame>());
            this.getFrameList().add(createEmptyTest("frame1BarCodeXXXX"));
        }
        else {
            this.getFrameList().set(0,createEmptyTest("frame1BarCodeXXXX"));
        }
        this.setDate(new Date());
        this.setReagentBarcode("regBarCodeXXXXX");
    }
    protected Frame createEmptyTest(String barCode){
        Frame frame = new Frame();
        frame.setBarcode(barCode);
        if(frame.getAllergicElementList()==null){
            frame.setAllergicElementList(new ArrayList<AllergicElement>());
        }
        for(int i = 1; i<4; i++){
            AllergicElement allergicElement = new AllergicElement();
            allergicElement.setType("i18n."+1);
            allergicElement.setValue(i);
            frame.getAllergicElementList().add(allergicElement);
        }
        
         DemoConfiguratorMatrix dcm = new DemoConfiguratorMatrix();
        dcm.setGuiAction(FactoryGuiActionProxy.standardGuiAction);
        frame.setMatrix(dcm.getMatrixOne());
         
        
        return frame;
    }
    
	
}